﻿using System;
using System.Text;
using System.Web.UI;
using TQ.Sharepoint.Webparts.TwitterWebpart.Utilities;

namespace TQ.Sharepoint.Webparts.TwitterWebpart
{
    public partial class TwitterWebpartUserControl : UserControl
    {
        public string Query { get; set; }
        public string MaxTweets { get; set; }
        public string TweetsPerPage { get; set; }

        protected void Page_PreRender(object sender,EventArgs e)
        {
            var globalScript = new StringBuilder();
            globalScript.Append("<script type=text/javascript>");
            globalScript.Append("TQWEET_GLOBAL = {query: '" + Query + "',maxTweets: " + MaxTweets + ",tweetsPerPage: " + TweetsPerPage + "};");
            globalScript.Append("</script>");
            var litTqweetGlobal = new LiteralControl { Text = globalScript.ToString() };
            Controls.AddAt(0, litTqweetGlobal);


            var refSCripts = new StringBuilder();
            refSCripts.Append("jquery.min.js".EncloseScript());
            refSCripts.Append("tweetify.js".EncloseScript());
            refSCripts.Append("tqweet.paging.js".EncloseScript());
            refSCripts.Append("tqweet.js'".EncloseScript());
            refSCripts.Append("Tqwitter.css'".EncloseStyle());
            var litRefScripts = new LiteralControl {Text = refSCripts.ToString()};
            Controls.AddAt(1, litRefScripts);
        }

    }
}
